﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using static System.Web.Razor.Parser.SyntaxConstants;
using System.Web.Mvc;
using System.Web.Http;

namespace LogisticsAndongApi.Models
{
    /// <summary>
    /// 后台用户相关API的基类
    /// </summary>
    public class ApiControllerBase : Controller
    {

        #region 设置应答报文
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected ResultDto SuccessResult()
        {
            return new ResultDto()
            {
                ResultCode = "000",
                ResultMsg = "OK",
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected ResultDto SuccessResult(string resultMsg)
        {
            return new ResultDto()
            {
                ResultCode = "000",
                ResultMsg = resultMsg,
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <returns></returns>
        protected ResultDto<T> SuccessResult<T>(T data)
        {
            return new ResultDto<T>()
            {
                ResultCode = "000",
                ResultMsg = "OK",
                Data = data
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resultMsg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        protected ResultDto<T> SuccessResult<T>(string resultMsg, T data)
        {
            return new ResultDto<T>()
            {
                ResultCode = "000",
                ResultMsg = resultMsg,
                Data = data
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resultMsg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        protected ResultDto<T> SuccessResult<T>(T data, string resultMsg)
        {
            return new ResultDto<T>()
            {
                ResultCode = "000",
                ResultMsg = resultMsg,
                Data = data
            };
        }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resultCode">000：成功, 110-199:业务异常, 200：系统错误</param>
        /// <param name="resultMsg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        protected ResultDto<T> ErrorResult<T>(string resultCode, string resultMsg = "系统繁忙，请稍后再试", T data = default(T))
        {
            return new ResultDto<T>()
            {
                ResultCode = resultCode,
                ResultMsg = resultMsg,
                Data = data
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resultCode">000：成功, 110-199:业务异常, 200：系统错误</param>
        /// <param name="resultMsg"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        protected ResultDto<T> ErrorResult<T>(string resultCode, T data, string resultMsg = "系统繁忙，请稍后再试")
        {
            return new ResultDto<T>()
            {
                ResultCode = resultCode,
                ResultMsg = resultMsg,
                Data = data
            };
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="resultCode">000：成功, 110-199:业务异常, 200：系统错误</param>
        /// <param name="resultMsg"></param>
        /// <returns></returns>
        protected ResultDto ErrorResult(string resultCode, string resultMsg = "系统繁忙，请稍后再试")
        {
            return new ResultDto()
            {
                ResultCode = resultCode,
                ResultMsg = resultMsg,
            };
        }


        #endregion


    }
}
